package fi.internetix.tidyclipboard;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

public class ServletCtxListener implements ServletContextListener {

  @Override
  public void contextDestroyed(ServletContextEvent arg0) {
  
  }
  
  @Override
  public void contextInitialized(ServletContextEvent event) {
    ServletContext servletContext = event.getServletContext();
    FileReader fileReader;
    try {
      String webAppPath = servletContext.getRealPath("/");
      fileReader = new FileReader(webAppPath + "WEB-INF/classes/settings.properties");
      System.getProperties().load(fileReader); 
      System.setProperty("log4j.appender.tcservlet.file", System.getProperty("logdir") + "servlet.log");
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }          
  }

}
